
package cz.czu.pef.DataModelling.ejb.impl;

import java.util.List;
import java.util.logging.Logger;

import javax.ejb.*;
import javax.interceptor.Interceptors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cz.czu.pef.DataModelling.dao.*;
import cz.czu.pef.DataModelling.ejb.api.*;

@Service(value="dataModellingService")
// ##################################################
// JBOSS6 CR1 has a lot of ClassLoading issues => even moving EJB JAR to WAR didn't help => disable EJB completely for this moment
// - also change app-prod-service.xml to lookup for EJB's JNDI again...
// ##################################################
@Stateless(name = "dataModellingServiceEJB", mappedName="dataModellingServiceEJB")
@Remote
// ##################################################
// Note: SpringBeanAutowiringInterceptor requires beanRefContext.xml to be defined (on EAR level)
// ##################################################
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class DataModellingServiceImpl implements DataModellingService
{
	Logger logger = Logger.getLogger(DataModellingServiceImpl.class.getName());

	@Autowired DataModellingDao dataModellingDao;

	@Transactional(timeout=30, propagation=Propagation.REQUIRED, readOnly=true)
	public List<Object[]> getAllMissingTrainings()
	{
		return dataModellingDao.getAllMissingTrainings();
	}

	@Transactional(timeout=30, propagation=Propagation.REQUIRED, readOnly=true)
	public List<Object[]> getAllMissingMedicalExaminations()
	{
		return dataModellingDao.getAllMissingMedicalExaminations();
	}
}
